package at.pervasive.mp3player.actions;

import java.awt.event.ActionEvent;

import javax.swing.Icon;

import at.pervasive.mp3player.Mp3Player;

public class MuteUnmuteAction extends AbstractMp3PlayerAction
{

	private final Icon muteIcon, unmuteIcon;

	public MuteUnmuteAction(Mp3Player player)
	{
		super(player);

		unmuteIcon = getIcon("volume-max.png");
		muteIcon = getIcon("volume-mute.png");

		resetIcon();
	}

	private void resetIcon()
	{
		putValue(LARGE_ICON_KEY, player.isMute() ? unmuteIcon : muteIcon);
	}

	@Override
	public void actionPerformed(ActionEvent e)
	{
		if (player.isMute())
			player.unmute();
		else
			player.mute();

		resetIcon();
	}

}
